<?php

class LogoutController extends Controller{
    
    function actionIndex(){
        $this->actionDo();
    }
    
    function actionDo(){
        if(!Yii::app()->user->isAuth()){
            $this->redirect($this->createUrl('login/do'));
        }
        Yii::app()->user->logout();
        $this->redirect(Yii::app()->user->getBackUrl());
    }
    
}
